// Target server hostname or IP address
const TARGET_SERVER_HOST = process.env.TARGET_SERVER_HOST ? process.env.TARGET_SERVER_HOST.trim() : '';
// Target server username
const TARGET_SERVER_USER = process.env.TARGET_SERVER_USER ? process.env.TARGET_SERVER_USER.trim() : '';
// Target server application path
const TARGET_SERVER_APP_PATH = `/home/${TARGET_SERVER_USER}/app`;
// Your repository
const REPO = 'ssh://git@gitlab.hyd-vpc.com:2289/accel/hyper-workbench-serv.git';

module.exports = {
    apps: [
        {
            name: 'workbench-admin',
            script: './server/app.js',
            env: {
                NODE_ENV: 'development',
                PORT: 8816
            },
            env_production: {
                NODE_ENV: 'production',
                PORT: 9806
            }
        }
    ],
    deploy: {
        production: {
            user: TARGET_SERVER_USER,
            host: TARGET_SERVER_HOST,
            ref: 'origin/master',
            repo: REPO,
            ssh_options: 'StrictHostKeyChecking=no',
            path: TARGET_SERVER_APP_PATH,
            'post-deploy': 'npm install --production'
                + ' && pm2 startOrRestart ecosystem.config.js --env=production'
                + ' && pm2 save'
        }
    }
};
